import Vue from 'vue'
import App from './App.vue'
import router from './router'
//引入nprogress
import NProgress from 'nprogress'
import 'nprogress/nprogress.css' //这个样式必须引入
//第三方插件
import echarts from 'echarts'
import VueAwesomeSwiper from 'vue-awesome-swiper'
import GeminiScrollbar from 'vue-gemini-scrollbar'
//引入element
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
// 简单配置NProgress
NProgress.inc(0.2)
NProgress.configure({ easing: 'ease', speed: 500, showSpinner: false })

router.beforeEach((to,from,next) => {
  NProgress.start()
  next()
})

router.afterEach(() => {
  NProgress.done()
})

//使用vuex引入当前的store
import store from './store'
// import Cesium from "cesium/Cesium"
// import "cesium/Widgets/widgets.css"
import './assets/styles/reset.css'
import './assets/styles/iconfont.css'
import 'swiper/dist/css/swiper.css'


import comjs from './CesiumPlugin.js' //引入公用js


Vue.prototype.$comjs = comjs; //

Vue.config.productionTip = false
Vue.prototype.$echarts = echarts
// Vue.prototype.Cesium = Cesium

// 添加全局事件监控方法
Vue.prototype.resetSetItem = function (key, newVal) {
  if (key === 'headerCity') {

      // 创建一个StorageEvent事件
      var newStorageEvent = document.createEvent('StorageEvent');
      const storage = {
          setItem: function (k, val) {
              localStorage.setItem(k, val);

              // 初始化创建的事件
              newStorageEvent.initStorageEvent('setItem', false, false, k, null, val, null, null);

              // 派发对象
              window.dispatchEvent(newStorageEvent)
          }
      }
      return storage.setItem(key, newVal);
  }
}



Vue.prototype.bus = new Vue()
Vue.use(VueAwesomeSwiper)
Vue.use(GeminiScrollbar)
Vue.use(ElementUI);

new Vue({
  router,
  store,
  render: h => h(App),
  mounted(){
    this.$store.commit("getDate");
  }
}).$mount('#app')
